<template>
	<view class="w100">
		<u-navbar back-text="" title="个人信息"></u-navbar>
		<view class="bg-white">
			<view class=" u-p-40" >
				<view class="u-row-between u-flex">
					<view class="">姓名</view>
					<view class="u-p-l-30 text-right">
						<input placeholder="姓名" v-model="submit_data.realname" disabled="disabled" />
					</view>
				</view>
			</view>
			<u-line/>
			<view class=" u-p-40">
				<view class="u-row-between u-flex">
					<view class="">账号</view>
					<view class=" u-p-l-30 text-right">
						<input placeholder="账号" v-model="submit_data.username" disabled="disabled"/>
					</view>
				</view>		
			</view>	
			<u-line/>
			<view class=" u-p-40">
				<view class="u-row-between u-flex">
					<view class="">手机号码</view>
					<view class=" u-p-l-30 text-right">
						<input placeholder="手机号码" v-model="submit_data.phone_number" disabled="disabled"/>
					</view>
				</view>		
			</view>	
			<u-line/>
			<!-- <view class=" u-p-40">
				<view class="u-row-between u-flex">
					<view class="">密码</view>
					<view class=" u-p-l-30 text-right">
						<input te placeholder="修改密码"/>
					</view>
				</view>		
			</view>	 -->
		</view>
	</view>
</template>
<script>
	import url from '../../main.js';
	export default {
		data() {
			return {
				login:false,
				submit_data:'',
			}
		},
		onLoad:function(data){
			try {
				//从本地缓存中同步获取指定 key 对应的内容。
				const value = uni.getStorageSync('userinfo');
				if (value) {
					this.submit_data = value;
					this.login = true;
				}else{
					uni.navigateTo({
						url:"/pages/login/login"
					})
					return;
				}
			} catch (e) {
				// error
			}
			//获取个人信息
			var pdata = url.getSignStr(this.submit_data);
			uni.request({
				url:url.websiteUrl+'user/xinfo',
				method:'POST',
				dataType:'json',
				header:{
					'content-type':'application/x-www-form-urlencoded'
				},
				data:pdata,
				success: res => {
					this.submit_data = res.data.data;
				}
			});
		},
		methods: {
			edit(){
				var pdata = url.getSignStr(this.submit_data);
				uni.request({
					url:url.websiteUrl+'user/xinfo',
					method:'POST',
					dataType:'json',
					header:{
						'content-type':'application/x-www-form-urlencoded'
					},
					data:pdata,
					success: res => {
						if(res.data.code!=1){
							uni.showToast({
								icon: 'none',
								title: res.data.info
							});
							return;
						}
						//跳回到会员中心
						uni.navigateBack({
							delta: 1
						});
						return;
					}
				});
			}
		}
	}
</script>

<style>
	
</style>
